//
// Created by the DataSnap proxy generator.
// 

unit ClientClass1;

interface

uses DBXCommon, Classes, SysUtils, DB, SqlExpr, DBXDBReaders;

type
  TDSServerModule2Client = class
  private
    FDBXConnection: TDBXConnection;
    FInstanceOwner: Boolean;
    FGetTimeCommand: TDBXCommand;
    FGetAttachCommand: TDBXCommand;
  public
    constructor Create(ADBXConnection: TDBXConnection); overload;
    constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
    destructor Destroy; override;
    function GetTime: TDateTime;
    function GetAttach: TDataSet;
  end;

  TDSServerModule4Client = class
  private
    FDBXConnection: TDBXConnection;
    FInstanceOwner: Boolean;
  public
    constructor Create(ADBXConnection: TDBXConnection); overload;
    constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
    destructor Destroy; override;
  end;

implementation

function TDSServerModule2Client.GetTime: TDateTime;
begin
  if FGetTimeCommand = nil then
  begin
    FGetTimeCommand := FDBXConnection.CreateCommand;
    FGetTimeCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGetTimeCommand.Text := 'TDSServerModule2.GetTime';
    FGetTimeCommand.Prepare;
  end;
  FGetTimeCommand.ExecuteUpdate;
  Result := FGetTimeCommand.Parameters[0].Value.AsDateTime;
end;

function TDSServerModule2Client.GetAttach: TDataSet;
begin
  if FGetAttachCommand = nil then
  begin
    FGetAttachCommand := FDBXConnection.CreateCommand;
    FGetAttachCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGetAttachCommand.Text := 'TDSServerModule2.GetAttach';
    FGetAttachCommand.Prepare;
  end;
  FGetAttachCommand.ExecuteUpdate;
  Result := TCustomSQLDataSet.Create(nil, FGetAttachCommand.Parameters[0].Value.GetDBXReader(False), True);
  Result.Open;
  if FInstanceOwner then
    FGetAttachCommand.FreeOnExecute(Result);
end;


constructor TDSServerModule2Client.Create(ADBXConnection: TDBXConnection);
begin
  inherited Create;
  if ADBXConnection = nil then
    raise EInvalidOperation.Create('Connection cannot be nil.  Make sure the connection has been opened.');
  FDBXConnection := ADBXConnection;
FInstanceOwner := True;
end;


constructor TDSServerModule2Client.Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean);
begin
  inherited Create;
  if ADBXConnection = nil then
    raise EInvalidOperation.Create('Connection cannot be nil.  Make sure the connection has been opened.');
  FDBXConnection := ADBXConnection;
FInstanceOwner := AInstanceOwner;
end;


destructor TDSServerModule2Client.Destroy;
begin
  FreeAndNil(FGetTimeCommand);
  FreeAndNil(FGetAttachCommand);
  inherited;
end;


constructor TDSServerModule4Client.Create(ADBXConnection: TDBXConnection);
begin
  inherited Create;
  if ADBXConnection = nil then
    raise EInvalidOperation.Create('Connection cannot be nil.  Make sure the connection has been opened.');
  FDBXConnection := ADBXConnection;
FInstanceOwner := True;
end;


constructor TDSServerModule4Client.Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean);
begin
  inherited Create;
  if ADBXConnection = nil then
    raise EInvalidOperation.Create('Connection cannot be nil.  Make sure the connection has been opened.');
  FDBXConnection := ADBXConnection;
FInstanceOwner := AInstanceOwner;
end;


destructor TDSServerModule4Client.Destroy;
begin
  inherited;
end;

end.
